.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MS-SYS 1 "December 26, 2015"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
ms-sys \- write Microsoft boot block
.SH SYNOPSIS
.B ms-sys
.RI "[options] [device]"
.SH DESCRIPTION
\fBms-sys\fP is for writing Microsoft compatible boot records.
.SH OPTIONS
A summary of options is included below.
.TP
.B \-1, \-\-fat12
Write a FAT12 floppy boot record to device.
.TP
.B \-2, \-\-fat32nt
Write a FAT32 partition NT boot record to device.
.TP
.B \-e, \-\-fat32pe
Write a FAT32 partition PE boot record to device, for USB install and recovery.
.TP
.B \-3, \-\-fat32
Write a FAT32 partition DOS (Win9x) boot record to device.
.TP
.B \-4, \-\-fat32free
Write a FAT32 partition FreeDOS boot record to device.
.TP
.B \-5, \-\-fat16free
Write a FAT16 partition FreeDOS boot record to device.
.TP
.B \-6, \-\-fat16
Write a FAT16 partition DOS (Win9x) boot record to device.
.TP
.B \-n, \-\-ntfs
Write a NTFS partition Windows 7 boot record to device. This
functionality should be considered experimental and probably
is of no practical use.
.TP
.B \-o, \-\-fat16ros
Write a FAT16 partition ReactOS boot record to device.
.TP
.B \-c, \-\-fat32ros
Write a FAT32 partition ReactOS boot record to device.
.TP
.B \-q, \-\-fat32kos
Write a FAT32 partition KolibriOS boot record to device.
.TP
.B \-l, \-\-wipelabel
Reset partition disk label in boot record.
.TP
.B \-p, \-\-partition
Write partition info (hidden sectors, heads and drive id) to boot
record. This might be needed on some partitions depending on
which program was used to create the file system.
.TP
.B \-H <n>, \-\-heads <n>
Set number of heads written with -p switch.
.TP
.B \-O <s>, \-\-writeoem <s>
Write OEM ID string <s> to file system.
.TP
.B \-S <x>, \-\-writewds <x>
Write Windows Disk Signature hexadecimal <x> to MBR.
.TP
.B \-7, \-\-mbr7
Write a Windows 7 master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd).
This MBR will boot certain partition types beyond cylinder
1024 using LBA addressing.
.TP
.B \-i, \-\-mbrvista
Write a Windows Vista master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd).
This MBR will boot certain partition types beyond cylinder
1024 using LBA addressing.
.TP
.B \-m, \-\-mbr
Write a Windows 2000/XP/2003 master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd).
This MBR will boot certain partition types beyond cylinder 
1024 using LBA addressing.
.TP
.B \-9, \-\-mbr95b
Write a Windows 95B/98/98SE/ME master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd) or 
boot drive and time (bytes 00da-00df).
This MBR will boot FAT-LBA partition types 0c and 0e beyond cylinder 
1024 using LBA addressing.
.TP
.B \-d, \-\-mbrdos
Write a DOS/Windows NT master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd).
This MBR will not boot beyond cylinder 1024 as it does not support 
LBA addressing.
.TP
.B \-s, \-\-mbrsyslinux
Write a syslinux master boot record to device.
Does not change Windows Disk Signature (bytes 01b8-01bd).
This MBR will boot any partition types beyond cylinder 
1024 using LBA addressing.
.TP
.B \-t, \-\-mbrgptsyslinux
Write a GPL syslinux GPT MBR to device.
This MBR will boot from a GPT partition table.
.TP
.B \-a, \-\-mbrreactos
Write a ReactOS MBR to device.
.TP
.B \-k, \-\-mbrkolibrios
Write a KolibriOS MBR to device.
.TP
.B \-r, \-\-mbrrufus
Write a Rufus MBR to device.
.TP
.B \-g, \-\-mbrgrub4dos
Write a Grub4Dos MBR to device.
.TP
.B \-b, \-\-mbrgrub2
Write a Grub 2 MBR to device.
.TP
.B \-z, \-\-mbrzero
Write an empty (zeroed, non-bootable) master boot record to device.
Zeroes all bytes except the partition map and signature id (bytes 01be-01ff).
Similar to the empty DOS partition table that fdisk creates.
.TP
.B \-f, \-\-force
Force writing of boot record.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show program version.
.TP
.B \-w, \-\-write
Write automatically selected boot record to device.
.P
If ms-sys is started without any options a simple diagnosis will be done on
the given device.
.br
.SH EXAMPLES
.P
Please note that Windows ME is not useful for making standalone bootable
floppies. However, Win9x and DOS works fine with the first two examples.
.P
.B Creating a 1.68 MB bootable floppy
.TP
This example assumes that you have your windows installation mounted at /dosc and also have mtools and fdformat installed.
.P
fdformat /dev/fd0u1680
.br
mformat a:
.br
ms-sys -w /dev/fd0
.br
mcopy /dosc/io.sys a:
.br
mcopy /dosc/msdos.sys a:
.br
mcopy /dosc/command.com a:
.P
.B Creating a bootable 2.8 MB floppy image to use with an el-torito bootable CD
.P
dd if=/dev/zero of=floppy288.img bs=1024 count=2880
.br
/sbin/mkdosfs floppy288.img
.br
ms-sys -1 -f floppy288.img
.br
su
.br
mount -o loop floppy288.img /mnt
.br
cp msdos.sys /mnt/
.br
cp io.sys /mnt/
.br
cp command.com /mnt/
.br
(it might also be a good idea to add a config.sys and autoexec.bat with CDROM support)
.br
umount /mnt
.br
exit
.br
cp floppy288.img cd-files/boot.img
.br
mkisofs -b boot.img -c boot.cat -o cdimage.iso cd\-files
.br
(burn the file cdimage.iso to a CD with cdrecord or another program)
.P
.B  restoring a backup of Win9x or Win ME to a fresh hard disk
.P
Step 1, use GNU parted to create your FAT32 partition and file system:
.P
parted (then create partition and file system)
.P
Step 2, write the MBR:
.P
ms-sys -w /dev/hda
.P
Step 3, write the FAT32 partition boot record:
.P
ms-sys -w /dev/hda1
.P
Step 4, mount your new filesystem:
.P
mount /dev/hda1 /mnt
.P
Step 5, read your backup
.P
cd /mnt; tar -xzvf /path/to/my_windows_backup_file.tgz
.br
.SH ENVIRONMENT
The variables LANG and LC_ALL have  the usual meaning, however there are not
many translations available.
.br
.SH BUGS
There have been reports about unbootable FAT32 partitions created with
"mformat -F c:". The problem has also been reported on partitions
formatted with mkdosfs and mkfs.vfat. One workaround is to use gnu parted
to create the partition instead. Since version 1.1.3 ms-sys has the switch
\-p which is supposed to fix this problem. Unfortunately, when using ms-sys
with Linux kernel 2.6 nor the \-p switch or gnu parted might work. A simple
workaround is to use ms-sys with Linux kernel 2.4. Another possible workaround
is to manually set the number of heads with the switch -H. If the system has
been booted by LILO, the correct number of heads can be given by "lilo -T geom".
.P
The writing of NTFS partition boot records in ms-sys probably has no practical use.
For Windows 7 it has been reported that doing "sysprep" before making an image of
an NTFS partition will make the partition restored from the image bootable.
.SH AUTHOR
This manual page was originally written by G\[:u]rkan Seng\[:u]n and since
edited by Henrik Carlqvist. The program ms-sys is mostly written by
Henrik Carlqvist, the file CONTRIBUTORS in the source archive contains a
complete list of contributors.
.SH SEE ALSO
mformat(1)  fdformat(8)  mkdosfs(8)  mkisofs(8)  parted(8)
